package examples.mail;

import java.util.Random;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class Util {

	private static Random randGen = new Random();
	private static char[] numbersAndLetters = ("0123456789abcdefghijklmnopqrstuvwxyz"
			+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray();;
	private static char[] numbers = ("0123456789").toCharArray();;

	public static String randomString(int length) {

		char[] randBuffer = new char[length];
		for (int i = 0; i < randBuffer.length; i++) {
			randBuffer[i] = numbersAndLetters[randGen.nextInt(71)];
		}
		return new String(randBuffer);
	}

	public static String randomNumberString(int length) {
		char[] randBuffer = new char[length];

		for (int i = 0; i < randBuffer.length; i++) {
			randBuffer[i] = numbersAndLetters[randGen.nextInt(9)];
		}

		return new String(randBuffer);

	}

	public static void changeip() throws Exception {
		Connection conn = Jsoup.connect("http://192.168.1.1/");
		conn.header("Authorization", "Basic YWRtaW46YWRtaW4=");
		Document d = conn.get();

		String disconnUrl = "http://192.168.1.1/userRpm/StatusRpm.htm?Disconnect=%B6%CF%20%CF%DF&wan=1";
		Connection conn1 = Jsoup.connect(disconnUrl);
		conn1.header("Authorization", "Basic YWRtaW46YWRtaW4=");
		Document d1 = conn1.get();

		String connUrl = "http://192.168.1.1/userRpm/StatusRpm.htm?Connect=%C1%AC%20%BD%D3&wan=1";
		Connection conn2 = Jsoup.connect(connUrl);
		conn2.header("Authorization", "Basic YWRtaW46YWRtaW4=");
		Document d2 = conn2.get();
		
		Thread.sleep(10000);
	}

	public static void main(String[] args) throws Exception {
		Util.changeip();
	}

}
